import sys
class NDFSError(Exception):
    default_message = "Unspecified NetDiskFS error."

    def __init__(self,msg=None,details=None):
        if msg is None:
            msg = self.default_message
        self.msg = msg
        self.details = details

    def __str__(self):
        keys = {}
        for k,v in self.__dict__.iteritems():
            if isinstance(v,unicode):
                v = v.encode(sys.getfilesystemencoding())
            keys[k] = v
        return str(self.msg % keys)

    def __unicode__(self):
        return unicode(self.msg) % self.__dict__

    def __reduce__(self):
        return (self.__class__,(),self.__dict__.copy(),)

class NDFSNetError(NDFSError):
    default_message = "Network Error"

class NDFSDataError(NDFSError):
    defualt_message = "Data Error"

class NDFSNeedToImplement(NDFSError):
    defualt_message = "NeedToImplement"
